package mh.demo.other;

public class PrintUtils {

    /**
     * 将当前方法打印出来
     * 格式：[threadName]className.methodName:content
     */
    public static void println(Object content) {
        final StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
        final StackTraceElement stackTraceEle = stackTrace[2];
        final String className = stackTraceEle.getClassName();
        String simpleClassName = className.substring(className.lastIndexOf(".") + 1);
        String head = "[" + Thread.currentThread().getName() + "]" + simpleClassName + "." + stackTraceEle.getMethodName();
        System.out.println(head + ": " + content);
    }

}
